<?php
namespace Admin\Controller;

use Common\Controller\AdminbaseController;

class ScoreboardLogController extends AdminbaseController{
	
	public function index(){
		if(!empty($_GET['event_name']) || !empty($_POST['event_name']))      $where['s.event_name']           = $_GET['event_name'] ? I('get.event_name') : I('post.event_name');
        if(!empty($_GET['customer_mobile']) || !empty($_POST['customer_mobile'])) $where['c.mobile'] = $_GET['customer_mobile'] ? I('get.customer_mobile') : I('post.customer_mobile'); 
        if(!empty($_GET['auth_code']) || !empty($_POST['auth_code']))       $where['s.auth_code']             = $_GET['auth_code'] ? I('get.auth_code') : I('post.auth_code');
        
        $this->assign('event_name',$where['s.event_name']);
        $this->assign('customer_mobile',$where['c.mobile']);
        $this->assign('auth_code',$where['s.auth_code']);
		
		$Scoreboard_log  = M('scoreboard_log');

	    $count = $Scoreboard_log->alias('s')->join('__CUSTOMER__ c on c.id = s.customer_id')->order('s.id desc')->where($where)->count();
		$page  = $this->page($count, 15);
       
		$scoreboard_log_list = $Scoreboard_log->alias('s')
		                                      ->join("__CUSTOMER__ c on c.id = s.customer_id","left")
		                                      ->order('s.id desc')
		                                      ->where($where)
		                                      ->limit($page->firstRow, $page->listRows)
		                                      ->select();
   
		//->where($where)->order('id desc')->select();
		$this->assign('list',$scoreboard_log_list);
		$this->assign("page", $page->show('Admin'));

		$this->display();
	}
}